﻿using System.Web.Mvc;
using MvcContrib.ActionResults;

namespace Peak.Web.Controllers.ErrorHandlers
{
  public class ProjectNotSelectedHandler : HandleErrorAttribute
  {
    public override void OnException(ExceptionContext filterContext)
    {
      if (filterContext.Exception is ProjectNotSelectedException)
      {
        filterContext.ExceptionHandled = true;
        filterContext.Result = new RedirectToRouteResult<ProjectsController>(f => f.CheckDefault());
      }
    }   
  }

}
